# coding:utf8
__author__ = 'Tony'

import random

from umeng_tool.analyse.models import VirtualUser
from umeng_tool.analyse.strategy.user_login_task import task as login_scheduler
from umeng_tool.analyse import consts


class Task:
    """
    每日新增任务
    """
    NEW_DESTINATION = consts.NEW_DESTINATION

    def __init__(self, login_scheduler):
        self.login_scheduler = login_scheduler

    def runner(self):
        """
        用户每日新增任务运行器
        """
        today_new_count = self.NEW_DESTINATION + random.choice(range(-consts.NEW_DESTINATION, consts.NEW_DESTINATION_OFFSET + 1))
        self.make_new(today_new_count)

        return today_new_count

    def make_new(self, count):
        user_new = VirtualUser.create_new(count)
        # self.login_scheduler.add_users(user_new)

task = Task(login_scheduler)